package com.xwd.web.student;

import com.xwd.service.StudentService;
import com.xwd.service.impl.StudentServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

@WebServlet("/findStuNo")
public class FindStunoServlet extends HttpServlet {
    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String stuNo = req.getParameter("stuNo");
        //查询数据库中有没有该学号
        StudentService service = new StudentServiceImpl();
        Boolean exist = service.findStuNoExist(stuNo);

        resp.setContentType("text/html;charset=UTF-8");
        PrintWriter writer = resp.getWriter();
        if(exist){
            writer.print("该学号已存在,不可用");
        }else{
            writer.print("该学号可用");
        }
    }
}
